<?php

namespace catchAdmin\pc\tables;

use catchAdmin\model\Area;
use catchAdmin\pc\tables\forms\Factory;
use catchAdmin\permissions\model\Permissions;
use catcher\CatchTable;
use catcher\library\table\Actions;
use catcher\library\table\HeaderItem;
use catcher\library\table\Search;
use catcher\library\form\Form;
use think\facade\Cache;

class Need extends CatchTable
{

    public function Table()
    {
        return $this
            ->getTable('need')
            ->header([
                HeaderItem::label('项目名')
                    ->prop('need_title'),
                HeaderItem::label('地址')
                    ->prop('need_city_name'),
                HeaderItem::label('是否加急')
                    ->prop('project_jia_ji_name'),
                HeaderItem::label('审核状态')
                    ->prop('status_name'),
                HeaderItem::label('操作')
                    ->actions([
                        Actions::view(),
//                        Actions::update(),
//                        Actions::delete(),
                    ])
                    ->width(260),
            ])
            ->withSearch([
                Search::label('项目名')
                    ->text('need_title', '项目名')
                    ->clearable(true),
                Search::label('是否加急')
                    ->select('project_jia_ji', '是否加急', tableSelectArray((new \catchAdmin\model\Need())->getProjectJiaJiList()))
                    ->clearable(true),
                Form::cascader('need_city_code', '地区', [])
                    ->options(
                        (new Area())
                            ->indexTree()
                    )
                    ->col(12)
                    ->props(Form::props('label', 'value', [
                        'checkStrictly' => true,
                    ]))
                    ->filterable(true)
                    ->clearable(true)
                    ->style(['width' => '100%']),

            ])
            ->selectionChange()
            ->withApiRoute('need')
            ->withActions([
//                Actions::create(),
            ])
            ->render();
    }


    public function form()
    {
        return Factory::create('need');
    }

}
